package com.edu.gcu.system.common;

import com.google.common.collect.Sets;

import javax.swing.event.InternalFrameAdapter;
import java.util.Set;

/**
 * @author polo
 * @version V1.0
 * @description: 常量类
 * @date 2018-02-08-14:49
 */

public class Const {
    public static final String CURRENT_ADMIN = "currentAdmin";

    public static final String NULL_ = "null";
    public static final String ADMIN = "admin";

    public interface ReportOrderBy {
        Set<String> CREATE_TIME_DESC_ASC = Sets.newHashSet("create_time-desc", "create_time-asc");
    }

    public interface ProductGiftOrderBy {
        Set<String> PRODUCT_GIFT_DESC_ASC = Sets.newHashSet("stock_desc", "stock_asc",
                "number_desc", "number_asc", "status_desc", "status_asc", "integral_desc", "integral_asc");
    }

    public interface RecordOrderBy {
        Set<String> RECORD_DESC_ASC = Sets.newHashSet("integral_desc", "integral_asc", "date_desc",
                "date_asc");
    }

    public interface UserOrderBy {
        Set<String> LOGIN_TIME_DESC_ASC = Sets.newHashSet("login_time-desc", "login_time-asc");
    }

    public interface IndentOrderBy {
        Set<String> INDENT_DESC_ASC = Sets.newHashSet("deliver_time-desc",
                "deliver_time-asc", "create_time-desc", "create_time-asc");
    }

    // 产品状态
    public enum ProductStatusEnum {
        ON_SALE(1, "可发货"),
        NO_SALE(2, "库存不足"),
        IS_DEL(3, "已删除");

        private String value;
        private int code;

        ProductStatusEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static ProductStatusEnum codeOf(int code) {
            for (ProductStatusEnum productStatusEnum : values()) {
                if (productStatusEnum.getCode() == code) {
                    return productStatusEnum;
                }
            }
            throw new RuntimeException(("没有对应枚举"));
        }
    }

    // 兑换商品状态
    public enum GiftStatusEnum {
        ON_SALE(1, "可兑换"),
        NO_SALE(2, "库存不足"),
        IS_DEL(3, "已删除");

        private String value;
        private int code;

        GiftStatusEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static GiftStatusEnum codeOf(int code) {
            for (GiftStatusEnum giftStatusEnum : values()) {
                if (giftStatusEnum.getCode() == code) {
                    return giftStatusEnum;
                }
            }
            throw new RuntimeException(("没有对应枚举"));
        }
    }

    // 订单状态
    public enum IndentStatusEnum {
        IS_DELIVER(1, "已发货"),
        NOT_DELIVER(2, "未处理"),
        NOT_SEND(3, "未出货");

        private String value;
        private int code;

        IndentStatusEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static IndentStatusEnum codeOf(int code) {
            for (IndentStatusEnum indentStatusEnum : values()) {
                if (indentStatusEnum.getCode() == code) {
                    return indentStatusEnum;
                }
            }
            throw new RuntimeException(("没有对应枚举"));
        }
    }

    // 出货表状态
    public enum ShipmentStatusEnum {
        NOT_SCAN_CODE(1, "未扫码出货"),
        NOT_DELIVER(2, "未收货"),
        IS_NOT_DELIVER(3, "确认收货"),
        LIMIT_NUM_FAIL(10, "库存不足,已发放所剩产品"),
        LIMIT_NUM_SUCCESS(20, "库存充足");

        private String value;
        private int code;

        ShipmentStatusEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static ShipmentStatusEnum codeOf(int code) {
            for (ShipmentStatusEnum shipmentStatusEnum : values()) {
                if (shipmentStatusEnum.getCode() == code) {
                    return shipmentStatusEnum;
                }
            }
            throw new RuntimeException(("没有对应枚举"));
        }
    }
}
